home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / keyboard.swg / 0042_Stuffing Keyboard.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-08-27  |  1.6 KB  |  64 lines

  1. {
  2. SEAN PALMER
  3.  
  4. >> I am assuming you already have a buffer-stuffer that takes a char and a
  5. >> scan code as input, so I won't post mine.
  6.  
  7. >No, I don't have a keyboard buffer-stuffer.
  8.  
  9. You said you wanted one that DIDN'T need you to tell it what a char's
  10. scancode was. Well, this would basically require a lookup table of
  11. possible scancodes for each ascii char... Plus some that don't have
  12. corresponding scancodes. What you could try is to just send a null (#0)
  13. to the routine as a scan code, I believe that's what happens when you
  14. enter a keystroke using the Alt-Numeric Keypad method... so it'd work as
  15. long as the program you're sending the keys to doesn't need the
  16. scancode.
  17.  
  18. Here's an untested version of the method that other guy sent to you...:
  19. }
  20.  
  21. procedure stuffKey(c : char; scan : byte); assembler;
  22. asm
  23.   mov cl, c
  24.   mov ch, scan
  25.   mov ah, 5
  26.   int $16
  27.   {al=0 if success, 1 if failed, but we just ignore that here}
  28. end;
  29.  
  30. so here's a call that just assumes a 0 scan code
  31.  
  32. procedure stuffChar(c : char); assembler;
  33. asm
  34.   mov cl,c
  35.   xor ch,ch
  36.   mov ah,5
  37.   int $16
  38. end;
  39.  
  40. {
  41. If you don't wanna go through the BIOS you can do it directly like this:
  42. (plus this is 'pure' Turbo Pascal code.. 8) }
  43.  
  44. var
  45.   head     : word absolute $40 : $1A;
  46.   tail     : word absolute $40 : $1C;
  47.   bufStart : word absolute $40 : $80;
  48.   bufEnd   : word absolute $40 : $82;
  49.  
  50. procedure stuffKey(c : char; scan : byte);
  51. begin
  52.   memW[$40 : tail] := word(scan) shl 8 + byte(c);
  53.   inc(tail, 2);
  54.   if tail = bufEnd then
  55.     tail := bufStart;
  56. end;
  57.  
  58. procedure clearBuffer;
  59. begin
  60.   tail := head;
  61. end;
  62.  
  63.  
  64.